package bean.life;

import bean.life.annotation.AnnotationConfig;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @date 2020/5/24 21:51
 */
public class Main {


	public static void testXML() throws Exception {
		ApplicationContext context
				= new ClassPathXmlApplicationContext("bean.life.xml/lifeTest.xml");
		System.out.println(context.getBean(bean.life.User.class));
		//手动关闭bean容器，在执行invoke之前会执行myDestroy
		context.getClass().getMethod("close").invoke(context);
	}


	public static void testAnnotation() throws Exception {
		ApplicationContext context
				= new AnnotationConfigApplicationContext(AnnotationConfig.class);
		System.out.println(context.getBean(User.class));
//		//手动关闭bean容器，在执行invoke之前会执行myDestroy
		context.getClass().getMethod("close").invoke(context);
	}

	public static void main(String[] args) throws Exception{
//		testAnnotation();
		testXML();
	}


}
